/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.modudf;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

public class MySQL {

    public static boolean startup() {
        int code = CMD.process("bat/mysql-startup.bat");
        CMD.checkCode(code, "MySQL");
        return (code == 0);
    }

    public static boolean shutdown() {
        int code = CMD.process("bat/mysql-shutdown.bat");
        CMD.checkCode(code, "MySQL");
        return (code == 0);
    }

    public static boolean serviceInstall() {
        int code = CMD.process("bat/mysql-service-install.bat");
        CMD.checkCode(code, "MySQL");
        return (code == 0);
    }

    public static boolean serviceRemove() {
        int code = CMD.process("bat/mysql-service-remove.bat");
        CMD.checkCode(code, "MySQL");
        return (code == 0);
    }
    
    public static boolean isRunning() {
        try {
            new Socket("localhost", 3306);
            return true;
        } catch (UnknownHostException uhe) {
            return false;
        } catch (IOException ioe) {
            return false;
        }
    }
}
